package cn.sdormitory.controller.evaluation;

import cn.sdormitory.common.api.CommonPage;
import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.evaluation.entity.WorkDayEntity;
import cn.sdormitory.evaluation.entity.WorkMonthInterviewEntity;
import cn.sdormitory.evaluation.service.WorkMonthInterviewService;
import cn.sdormitory.evaluation.vo.WorkDayVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Api(tags = "班主任月访谈")
@RequestMapping("/workmonth")
public class WorkMonthInterviewController {
    @Resource
    WorkMonthInterviewService workMonthInterviewService;

    /**
     * 查询任务列表
     * @param vo
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/pageList")
    public CommonResult<CommonPage> pageList(@RequestBody WorkMonthInterviewEntity vo) throws Exception {
        IPage<WorkMonthInterviewEntity> workMonthInterviewEntityIPage = workMonthInterviewService.pageList(vo);
        return CommonResult.success(CommonPage.restPage(workMonthInterviewEntityIPage));
    }

    /**
     * 修改访谈内容
     * @param vo
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/updateInterview")
    public CommonResult<CommonPage> updateInterview(@RequestBody WorkMonthInterviewEntity vo) throws Exception {
        int i = workMonthInterviewService.updateInterview(vo);
        if(i>0){
            return CommonResult.success();
        }
        return CommonResult.failed();
    }
}
